//28.找出字符串中第一个匹配项的下标
//https://leetcode.cn/problems/find-the-index-of-the-first-occurrence-in-a-string/
class Solution {
public:
    int strStr(string haystack, string needle) {
        // kmp算法学习
        int h = haystack.size(),n = needle.size();
        for(int i = 0;i<=h-n;++i)
        {
            int j = i,k = 0;
            while(k<n && haystack[j] == needle[k]) ++j,++k;
            if(k == n) return i;
        }
        return -1;
    }
};